<?php

namespace IDock\Insurance\QHIC\Response;

use IDock\Http\Response;
use IDock\Insurance\QHIC\Response\AllQHICResponse;
use IDock\Printer\PremiumUnderwritingPrinter;

class UnderwritingResponse extends AllQHICResponse
{

    /**
     * @var PremiumUnderwritingPrinter $printer
     */
    public $printer = PremiumUnderwritingPrinter::class;

    public function printerInit(): Response
    {
        $data = $this->getBody()['Underwrite'] ?? [];
        $code = $data['CUndrMrk'] ?? '1';

        $this->printer->messageTip = $data['CUndrMsg'] ?? '';

        //下发
        if ($code == '0') {
            $this->printer->statusCode = 'U4';
        }
        //成功
        if ($code == '2')  {
            $this->printer->statusCode = 'U1';
        }
        //人工
        if ($code == '1') {
            $this->printer->statusCode = 'U3';
        }

        return $this;
    }
}
